window.onload = function() {



  work1();
  function work1() {
    var minput = getid("minput");
    var minput2 = getid("minput2");
    var minput3 = getid("minput3");
    getid("btn").onclick = function() {
      if (!isNaN(minput.value) && !isNaN(minput2.value)) {
        minput3.value =
          minput.value * minput.value + minput2.value * minput2.value;

        minput3.value = Math.sqrt(
          Math.pow(minput.value, 2) + Math.pow(minput2.value, 2)
        );
        Math;
      } else {
        alert("输入的不为数字,请重新输入!!!!");
      }
    };
  }

  work2();
  function work2() {
    var y = getid("y");
    var m = getid("m");
    var d = getid("d");
    var btn2 = getid("btn2");
    btn2.onclick = function() {
      if (
        !isNaN(y.value) &&
        !isNaN(m.value) &&
        !isNaN(d.value) &&
        y.value.length >= 4
      ) {
        var str = y.value + "/" + m.value + "/" + d.value;
      } else {
        alert("请输入数字!!!!");
      }
      console.log(str);
      btn2.value = dateToString(new Date(str)).substring(21, 24);

      new Date();
    };
  }

  work3();
  function work3() {
    var md = new Date();
    var i = 0;
    var t = md.getTime(); //拿到时间截
    // console.log(new Date(t));
    console.log("----a-" + Conversiontime(t));
    var s1 = getid("s1");
    var s2 = getid("s2");
    var m1 = getid("m1");
    var m2 = getid("m2");
    var h1 = getid("h1");
    var h2 = getid("h2");
    var str = "";
    var arr = [];
    var mtime = setInterval(() => {
      i++;
      t += 1000;
      str = Conversiontime(t).substring(11, 19);
      arr = str.split("");
      for (let i = 0; i < arr.length; i++) {
        h1.src = "img/" + arr[0] + ".png";
        h2.src = "img/" + arr[1] + ".png";
        m1.src = "img/" + arr[3] + ".png";
        m2.src = "img/" + arr[4] + ".png";
        s1.src = "img/" + arr[6] + ".png";
        s2.src = "img/" + arr[7] + ".png";
      }

      // if (i==20) {
      //     clearInterval(mtime);

      // }
    }, 1000);
  }

  work4();
  function work4() {
    var arr = [
      "张一",
      "张2",
      "张3",
      "张4",
      "张5",
      "张6",
      "张7",
      "张8",
      "张9",
      "张10"
    ];
    var newarr = [];
    var str = "";
    var s = "";
    for (let i = 0; i < 5; i++) {
      s = getRand(0, 9);
      if (str.indexOf(s) < 0) {
        str += s;
        newarr.push(arr[s]);
      } else {
        i--;
      }
    }
    console.log(str);
    console.log(newarr);
  }
  work5();
  function work5() {
    var himg = getid("himg");
    var r = 1;
    var temp = 1;
    himg.onclick = function() {
      while (true) {
        if (r != temp) {
          himg.src = "img/" + r + "m.jpg";
          break;
        } else {
          r = getRand(1, 4);
        }
      }

      temp = r;
      // himg.scr = "img/3m.jpg";
    };
  }
  work6();
  function work6() {
    //由 字母 或 数字组成的验证码
    //  从 48--122 之间   ，随机获取一个整数  ，
    //  如果 这个随机整数在 58--64 或  91--96之间，说明不是数字或字母， 就重新抽取一个新的code值
    //  如果这个随机正则 不在58--64 或  91--96之间，说明是数字或字母，转成对应字符  进行字符串拼接
    console.log(getYZM(6));
    pick();
    getid("ma").onclick = function() {
      pick();
      console.log("点了A.....");
    };
  }
  function pick() {
    var mi = getid("mi");
    var mem = getid("mem");
    mi.innerText = getYZM(6);
    mi.style.backgroundImage = "url(img/bg1.png)";
    mem.innerText = getYZM(6);
    mem.style.backgroundImage = "url(img/bg1.png)";
  }
};
